package com.gohi.main.system.action;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.Date;
import java.util.List;

import javax.servlet.http.Cookie;

import net.sf.json.JSONArray;

import org.apache.log4j.Logger;

import com.gohi.core.web.action.BaseAction;
import com.gohi.main.store.service.IStoreService;
import com.gohi.main.system.hbm.ShopgooArea;
import com.gohi.main.system.hbm.ShopgooWxBrand;
import com.gohi.main.system.service.ISystemService;
import com.gohi.main.util.AppJsonUtils;
import com.gohi.main.util.Utils;
import com.gohi.main.util.WebUtils;
import com.gohi.main.util.Cache.MainCache;

import com.gohi.main.wxapi.util.AccoutUtil;
import com.gohi.main.wxapi.vo.JsApi;
import com.gohi.main.wxapi.vo.WxAccount;

/**
 * 系统相关的ACTION
 * 
 * @author Administrator
 * 
 */
public class SystemAction extends BaseAction {
	Logger logger = Logger.getLogger(SystemAction.class);
	private ISystemService systemService;
	// 商户
	private IStoreService storeService;
	// 测试地区
	public void getare() {
		AppJsonUtils.ptinrJson(systemService.getAre(), getRequest(),
				getResponse());
	}
	//优惠信息 暂时只做一个页面
	public String sale(){
		return "sale";
	}
	//首页
	public String index() {
		//查询所有的轮播图片
		List<ShopgooWxBrand> brand = systemService.getAllBrand();
		//查询美容项目
		this.getRequest().setAttribute("brand", brand);
		//查询地区
		this.getRequest().setAttribute("are", MainCache.getArealist());
		//List<BaseStoreClass> storeclass = storeService.getStoreClass();
		//查询商户类型
		//System.err.println(storeService.getStoreClass().size());
		this.getRequest().setAttribute("sclass", MainCache.getClasslist());
		
		
		// 查询cookie
		Cookie ck = WebUtils.getCookieByName(getRequest(), "city");
		if (ck == null) {
			WebUtils.addCookie(getResponse(), "city", "67-上海", -1);// 默认上海
		}
		
		return "index";
	}
	
	public String contact(){
		return "contact";
	}
	public ISystemService getSystemService() {
		return systemService;
	}

	public void setSystemService(ISystemService systemService) {
		this.systemService = systemService;
	}

	public IStoreService getStoreService() {
		return storeService;
	}

	public void setStoreService(IStoreService storeService) {
		this.storeService = storeService;
	}
		
}
